public class Main20250330 {
}

class Solution {
    public String addSpaces(String s, int[] spaces) {
        StringBuilder sb = new StringBuilder();
        int last = 0;
        for (int i : spaces) {
            sb.append(s.substring(last, i));
            sb.append(' ');
            last = i;
        }
        sb.append(s.substring(last, s.length()));
        return sb.toString();
    }
}